<?php
/**
 * @file
 * @author  Jakub Kraft <jakub.kraft@gmail.com>
 * @version 1.0
 */

class FlickrOEmbedAdapter extends OEmbedAdapter {
	
	public static $pattern = '/^http\:\/\/(www\.){0,1}flickr\.com\//i';
	
	public function resolveURL($url) {
		
		$curl_result = $this->_curlCall('http://www.flickr.com/services/oembed?url='.urlencode($url).'&format=json', false);
		$response = json_decode($curl_result['response'], true);
		
		if ($curl_result['info']['http_code'] != 404 && is_string($curl_result['response']) && strlen($curl_result['response']) > 0) {
			return json_decode ($curl_result['response'], true);
		} else {
			return array();
		}
	}
	
}